<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Counter</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

</head>
<body>
<div id="app">
    <button type="button" @click="add__1">-</button>
    <span>{{count}}</span>
    <button type="button" @click="add_1">+</button>
</div>

<script>
    const app = new Vue({
        el:"#app",
        data:{
            count:0
        },
        methods:{
            add_1:function () {
                if (this.count<10)
                {this.count = this.count+1}else {alert("别点啦，最大啦！")}
            },
            add__1:function () {
                if (this.count>0){this.count = this.count-1}else {alert("别点啦，最小啦！")}
            }
        }
    });
</script>
</body>
</html>
